package com.feidee.data.email.model;

import com.feidee.data.report.constant.Constant;
import com.feidee.data.report.util.JsonUtil;
import com.feidee.data.report.util.SimpleAES;

import java.io.IOException;
import java.util.Map;
import java.util.Properties;

public class EConstant {

    private static Properties props;
    protected static Map<String, String> dbMap;

    static {
        props = new Properties();
        try {
            props.load(EConstant.class.getClassLoader().getResourceAsStream(EConstant.EMAIL_API_CONFIG_PROPERTIES));
            dbMap = JsonUtil
                    .jsonToStrMap(SimpleAES.decrypt(props.getProperty("base_info").trim(), Constant.MYSQL_DECRYPT_KEY));
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static final String HIVE = "hive";
    public static final String MYSQL_DATA = "mysql";

    public static final String IMPALA = "impala";

    public static final String EMAIL_API_CONFIG_PROPERTIES = "api.properties";

    public static final String MYSQL_DATA_QUOTA = "quota";
    public static final String MYSQL_DATA_VALUE = "value";

    public static final String DEFULT_CHECK_CLASS = "com.feidee.data.email.check.DefaultCheckData";

    public static final String EMAIL_SEND_HOST = props.getProperty("email.send.host");
    public static final String EMAIL_SEND_PORT = props.getProperty("email.send.port");
    public static final String EMAIL_SEND_USER = props.getProperty("email.send.user");
    public static String EMAIL_SEND_PASSWORD = "SuiShouWanSui123";
    public static final String EMAIL_SEND_FROM = props.getProperty("email.send.from");

    public static String EMAIL_GET_DAILY_URL = "http://data.feidee.com/bigdata/rest/resources/mailreport/getData/mailDailyrep";
    public static String EMAIL_GET_WEEK_URL = "http://data.feidee.com/bigdata/rest/resources/mailreport/getData/mailWeekrep";

    public static final String EMAIL_DAILY_KEY = "business_analysis";
    public static final String EMAIL_WEEK_KEY = "business_analysis_week_report";
    public static final String EMAIL_TOPIC = "subjectData";
    public static final String EMAIL_CONTENT = "htmlData";
    public static final String EMAIL_IMAGES = "image";
    public static final String EMAIL_FILES = "file";

    public static final int EXECUTOR_THREAD_NUM = Integer.parseInt(props.getProperty("executor.thread.num"));
    public static final int QUERY_SIZE = Integer.parseInt(props.getProperty("queue.size"));

    public static final String EMAIL_LOG_APT = props.getProperty("email.log.apt", "bigdata");
    public static final String EMAIL_LOG_BUS = props.getProperty("email.log.bus", "email_report");

    public static final boolean TIME_SWITCH = Boolean.parseBoolean(props.getProperty("email.timer.switch", "false"));

    public static String EMAIL_QUARTZ_URL = "http://data.feidee.com/feidee-data-report/email/send.do?apt=123&key=136AD6D79A084FE7";

    public static String SEND_REPORT_MAIL_URL = "http://data.feidee.com/bigdata/rest/resources/mailSubscribe/send";

    //汇总邮件接收人
    public static String Exception_REPORT_MAIL_GATHER_RECEIVER = props.getProperty("exception.report.mail.gather.receiver");
    //未知异常邮件接收人
    public static String Exception_REPORT_MAIL_HANDLER_RECEIVER = props.getProperty("exception.report.mail.handler.receiver");
}
